<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1">
    <title>添加供应商</title>
    <link rel="shortcut icon" th:href="@{/pages/logo-1.ico}" href="../static/pages/logo-1.ico"/>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" href="../static/layui/css/layui.css">
    <link rel="stylesheet" th:href="@{/layui/css/admin.css}" href="../static/layui/css/admin.css">
    <link rel="stylesheet" th:href="@{/layui/css/log.css}" href="../static/layui/css/log.css">
</head>
<body>
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main">
        <div class=" layadmin-user-login-header">
            <h2>添加供应商</h2>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input type="text" name="id" id="name" lay-verify="required" placeholder="供应商名" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input type="text" name="name" id="address" lay-verify="required" placeholder="地址" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input type="text" name="unit" id="zip" lay-verify="required" placeholder="邮编" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input type="text" name="space" id="phone" lay-verify="required" placeholder="电话" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input type="text" name="supplierId" id="linkMan" lay-verify="required" placeholder="联系人" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input type="text" name="space" id="linkTel" lay-verify="required" placeholder="联系人电话" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input type="text" name="space" id="bank" lay-verify="required" placeholder="开户银行" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input type="text" name="space" id="bankAccount" lay-verify="required" placeholder="银行账号" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input type="text" name="space" id="email" lay-verify="required" placeholder="邮箱" class="layui-input">
            </div>
            <!--            <div class="layui-inline">-->
            <!--&lt;!&ndash;                <label class="layui-form-label">搜索选择框</label>&ndash;&gt;-->
            <!--                <div class="layui-input-inline">-->
            <!--                    <select name="modules" lay-verify="required" lay-search="">-->
            <!--                        <option value="">供应商编号</option>-->
            <!--                        <option value="1">layer</option>-->
            <!--                        <option value="2">form</option>-->
            <!--                    </select>-->
            <!--                </div>-->
            <!--            </div>-->
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit" onclick="submit();" id="addpurlog">确认</button>
            </div>
            <div class="layui-form-item">
                <a href="javascript:history.go(-1);" lay-filter="LAY-user-login-submit" class="layui-btn layui-btn-fluid"  id="out">取消</a>
            </div>
        </div>
    </div>
</div>

<script src="../static/layui/layui.js" th:src="@{/layui/layui.js}" type="text/javascript"></script>
<script src="../static/js/vue.min.js" th:src="@{/js/vue.min.js}" type="text/javascript"></script>
<script src="../static/js/jquery-3.6.3.min.js" th:src="@{/js/jquery-3.6.3.min.js}" type="text/javascript"></script>
<script th:inline="javascript">
    //Javascript代码区域
    // window.onload=function() {
    //     let user = [[${user}]];
    //     if (user == null || user == 0) {
    //         window.location.href = "/";
    //     }
    // }

    function submit(){
        let name = $('#name').val()
        let address = $('#address').val()
        let zip = $('#zip').val()
        let phone = $('#phone').val()
        let linkMan = $('#linkMan').val()
        let linkTel = $('#linkTel').val()
        let bank = $('#bank').val()
        let bankAccount = $('#bankAccount').val()
        let email = $('#email').val()
        $.ajax({
            url:"/sys/addgyszc",
            data:{
                name:name,
                address:address,
                zip:zip,
                phone:phone,
                linkMan:linkMan,
                linkTel:linkTel,
                bank:bank,
                bankAccount:bankAccount,
                email:email
            },
            type:"post",
            dataType :"json",
            // cache : false,
            // async : false,//设置同步（ajax请求此处需求为跳转而不是局部页面刷新）
            success:function (gysadd){
                if (gysadd==100) {
                    window.location.href = "/sys/sysgyszl";
                }else if (gysadd==200) {
                    layer.open({
                        title: ''
                        , content: '系统错误,请联系管理员!'
                    });
                }else {
                    // window.location.href = "/";
                    layer.open({
                        title: ''
                        ,content: '用户名重复，请重新输入!'
                    });
                }
            }
        })
    }
</script>
</body>
</html>
